/**
 * 
 */
package net.kaizhong.excel;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import net.kaizhong.excel.impl.ExcelOperateServiceImpl;

/**
 * @author huqifeng
 *
 */
public class ExcelOperateServiceTest {

    /**
     * 
     */
    public ExcelOperateServiceTest() {
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        ExcelOperateService<Study> ees = new ExcelOperateServiceImpl<Study>();
        List<Study> studyList = new ArrayList<Study>();
        for (int i = 0; i < 20; i++) {
            Study s = new Study();
            s.setId(i + 1);
            s.setName("name" + s.getId());
            if (i % 2 == 0) {
                s.setGender("F");
            } else {
                s.setGender("M");
            }
            s.setEnrollmentDate(new Date());
            s.setScore(Math.random() * 1000);
            studyList.add(s);
        }

        OutputStream out = null;
        try {
            // 导出
            // out = new FileOutputStream("D://testOne.xls");

            // ees.exportExcel("studySheet", studyList, out);

            // 导入
            File srcFile = new File("D://testOne.xls");
            ees.importExcel(srcFile, Study.class, true);

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (null != out) {
                try {
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }

}
